<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Eigen: Porting from Eigen2 to Eigen3</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="eigendoxy.css" rel="stylesheet" type="text/css">
<!--  -->
<script type="text/javascript" src="eigen_navtree_hacks.js"></script>
</head>
<body>
<div style="background:#FFDDDD;font-size:120%;text-align:center;margin:0;padding:5px">Please, help us to better know about our user community by answering the following short survey:  <a href="https://forms.gle/wpyrxWi18ox9Z5ae9">https://forms.gle/wpyrxWi18ox9Z5ae9</a></div>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Eigen_Silly_Professor_64x64.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://eigen.tuxfamily.org">Eigen</a>
   &#160;<span id="projectnumber">3.3.9</span>
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('Eigen2ToEigen3.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">Porting from Eigen2 to Eigen3 </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This page lists the most important API changes between Eigen2 and Eigen3, and gives tips to help porting your application from Eigen2 to Eigen3.</p>
<h1><a class="anchor" id="CompatibilitySupport"></a>
Eigen2 compatibility support</h1>
<p>Up to version 3.2 Eigen provides <a href="http://eigen.tuxfamily.org/dox-3.2/Eigen2SupportModes.html">Eigen2 support modes</a>. These are removed now, because they were barely used anymore and became hard to maintain after internal re-designs. You can still use them by first <a href="http://eigen.tuxfamily.org/dox-3.2/Eigen2ToEigen3.html">porting your code to Eigen 3.2</a>.</p>
<h1><a class="anchor" id="Using"></a>
The USING_PART_OF_NAMESPACE_EIGEN macro</h1>
<p>The USING_PART_OF_NAMESPACE_EIGEN macro has been removed. In <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3, just do: </p><div class="fragment"><div class="line"><span class="keyword">using namespace </span><a class="code" href="namespaceEigen.html">Eigen</a>;</div>
<div class="ttc" id="anamespaceEigen_html"><div class="ttname"><a href="namespaceEigen.html">Eigen</a></div><div class="ttdoc">Namespace containing all symbols from the Eigen library.</div><div class="ttdef"><b>Definition:</b> Core:309</div></div>
</div><!-- fragment --><h1><a class="anchor" id="ComplexDot"></a>
Dot products over complex numbers</h1>
<p>This is the single trickiest change between <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2 and <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3. It only affects code using <code>std::complex</code> numbers as scalar type.</p>
<p><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2's dot product was linear in the first variable. <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3's dot product is linear in the second variable. In other words, the <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2 code</p><div class="fragment"><div class="line">x.dot(y) </div>
</div><!-- fragment --><p> is equivalent to the <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3 code</p><div class="fragment"><div class="line">y.dot(x) </div>
</div><!-- fragment --><p> In yet other words, dot products are complex-conjugated in <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3 compared to <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2. The switch to the new convention was commanded by common usage, especially with the notation \( x^Ty \) for dot products of column-vectors.</p>
<h1><a class="anchor" id="VectorBlocks"></a>
Vector blocks</h1>
<table class="manual">
<tr>
<th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2</th><th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3 </th></tr>
<tr>
<td><div class="fragment"><div class="line">vector.start(length)</div>
<div class="line">vector.start&lt;length&gt;()</div>
<div class="line">vector.end(length)</div>
<div class="line">vector.end&lt;length&gt;()</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">vector.head(length)</div>
<div class="line">vector.head&lt;length&gt;()</div>
<div class="line">vector.tail(length)</div>
<div class="line">vector.tail&lt;length&gt;()</div>
</div><!-- fragment --> </td></tr>
</table>
<h1><a class="anchor" id="Corners"></a>
Matrix Corners</h1>
<table class="manual">
<tr>
<th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2</th><th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3 </th></tr>
<tr>
<td><div class="fragment"><div class="line">matrix.corner(TopLeft,r,c)</div>
<div class="line">matrix.corner(TopRight,r,c)</div>
<div class="line">matrix.corner(BottomLeft,r,c)</div>
<div class="line">matrix.corner(BottomRight,r,c)</div>
<div class="line">matrix.corner&lt;r,c&gt;(TopLeft)</div>
<div class="line">matrix.corner&lt;r,c&gt;(TopRight)</div>
<div class="line">matrix.corner&lt;r,c&gt;(BottomLeft)</div>
<div class="line">matrix.corner&lt;r,c&gt;(BottomRight)</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">matrix.topLeftCorner(r,c)</div>
<div class="line">matrix.topRightCorner(r,c)</div>
<div class="line">matrix.bottomLeftCorner(r,c)</div>
<div class="line">matrix.bottomRightCorner(r,c)</div>
<div class="line">matrix.topLeftCorner&lt;r,c&gt;()</div>
<div class="line">matrix.topRightCorner&lt;r,c&gt;()</div>
<div class="line">matrix.bottomLeftCorner&lt;r,c&gt;()</div>
<div class="line">matrix.bottomRightCorner&lt;r,c&gt;()</div>
</div><!-- fragment -->  </td></tr>
</table>
<p>Notice that Eigen3 also provides these new convenience methods: topRows(), bottomRows(), leftCols(), rightCols(). See in class <a class="el" href="classEigen_1_1DenseBase.html" title="Base class for all dense matrices, vectors, and arrays.">DenseBase</a>.</p>
<h1><a class="anchor" id="CoefficientWiseOperations"></a>
Coefficient wise operations</h1>
<p>In Eigen2, coefficient wise operations which have no proper mathematical definition (as a coefficient wise product) were achieved using the .cwise() prefix, e.g.: </p><div class="fragment"><div class="line">a.cwise() * b </div>
</div><!-- fragment --><p> In Eigen3 this .cwise() prefix has been superseded by a new kind of matrix type called <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a> for which all operations are performed coefficient wise. You can easily view a matrix as an array and vice versa using the <a class="el" href="classEigen_1_1MatrixBase.html#a354c33eec32ceb4193d002f4d41c0497">MatrixBase::array()</a> and <a class="el" href="classEigen_1_1ArrayBase.html#af01e9ea8087e390af8af453bbe4c276c">ArrayBase::matrix()</a> functions respectively. Here is an example: </p><div class="fragment"><div class="line">Vector4f a, b, c;</div>
<div class="line">c = a.array() * b.array();</div>
</div><!-- fragment --><p> Note that the .array() function is not at all a synonym of the deprecated .cwise() prefix. While the .cwise() prefix changed the behavior of the following operator, the array() function performs a permanent conversion to the array world. Therefore, for binary operations such as the coefficient wise product, both sides must be converted to an <em>array</em> as in the above example. On the other hand, when you concatenate multiple coefficient wise operations you only have to do the conversion once, e.g.: </p><div class="fragment"><div class="line">Vector4f a, b, c;</div>
<div class="line">c = a.array().abs().pow(3) * b.array().abs().sin();</div>
</div><!-- fragment --><p> With Eigen2 you would have written: </p><div class="fragment"><div class="line">c = (a.cwise().abs().cwise().pow(3)).cwise() * (b.cwise().abs().cwise().sin());</div>
</div><!-- fragment --><h1><a class="anchor" id="PartAndExtract"></a>
Triangular and self-adjoint matrices</h1>
<p>In <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2 you had to play with the part, extract, and marked functions to deal with triangular and selfadjoint matrices. In <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3, all these functions have been removed in favor of the concept of <em>views:</em> </p>
<table class="manual">
<tr>
<th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2</th><th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3 </th></tr>
<tr>
<td><div class="fragment"><div class="line">A.part&lt;UpperTriangular&gt;();</div>
<div class="line">A.part&lt;StrictlyLowerTriangular&gt;(); </div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">A.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Upper</a>&gt;()</div>
<div class="line">A.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda2424988b6fca98be70b595632753ba81">StrictlyLower</a>&gt;()</div>
<div class="ttc" id="agroup__enums_html_gga39e3366ff5554d731e7dc8bb642f83cda2424988b6fca98be70b595632753ba81"><div class="ttname"><a href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda2424988b6fca98be70b595632753ba81">Eigen::StrictlyLower</a></div><div class="ttdeci">@ StrictlyLower</div><div class="ttdef"><b>Definition:</b> Constants.h:216</div></div>
<div class="ttc" id="agroup__enums_html_gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1"><div class="ttname"><a href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Eigen::Upper</a></div><div class="ttdeci">@ Upper</div><div class="ttdef"><b>Definition:</b> Constants.h:206</div></div>
</div><!-- fragment --> </td></tr>
<tr>
<td><div class="fragment"><div class="line">A.extract&lt;UpperTriangular&gt;();</div>
<div class="line">A.extract&lt;StrictlyLowerTriangular&gt;();</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">A.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Upper</a>&gt;()</div>
<div class="line">A.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda2424988b6fca98be70b595632753ba81">StrictlyLower</a>&gt;()</div>
</div><!-- fragment --> </td></tr>
<tr>
<td><div class="fragment"><div class="line">A.marked&lt;UpperTriangular&gt;();</div>
<div class="line">A.marked&lt;StrictlyLowerTriangular&gt;();</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">A.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Upper</a>&gt;()</div>
<div class="line">A.triangularView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda2424988b6fca98be70b595632753ba81">StrictlyLower</a>&gt;()</div>
</div><!-- fragment --> </td></tr>
<tr>
<td colspan="2"></td></tr>
<tr>
<td><div class="fragment"><div class="line">A.part&lt;SelfAdfjoint|UpperTriangular&gt;();</div>
<div class="line">A.extract&lt;SelfAdfjoint|LowerTriangular&gt;();</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">A.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Upper</a>&gt;()</div>
<div class="line">A.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Lower</a>&gt;()</div>
<div class="ttc" id="agroup__enums_html_gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749"><div class="ttname"><a href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Eigen::Lower</a></div><div class="ttdeci">@ Lower</div><div class="ttdef"><b>Definition:</b> Constants.h:204</div></div>
</div><!-- fragment --> </td></tr>
<tr>
<td colspan="2"></td></tr>
<tr>
<td><div class="fragment"><div class="line">UpperTriangular</div>
<div class="line">LowerTriangular</div>
<div class="line">UnitUpperTriangular</div>
<div class="line">UnitLowerTriangular</div>
<div class="line">StrictlyUpperTriangular</div>
<div class="line">StrictlyLowerTriangular</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line"><a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Upper</a></div>
<div class="line"><a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Lower</a></div>
<div class="line"><a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdadd28224d7ea92689930be73c1b50b0ad">UnitUpper</a></div>
<div class="line"><a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda8f40b928c10a71ba03e5f75ad2a72fda">UnitLower</a></div>
<div class="line"><a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda7b37877e0b9b0df28c9c2b669a633265">StrictlyUpper</a></div>
<div class="line"><a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda2424988b6fca98be70b595632753ba81">StrictlyLower</a></div>
<div class="ttc" id="agroup__enums_html_gga39e3366ff5554d731e7dc8bb642f83cda7b37877e0b9b0df28c9c2b669a633265"><div class="ttname"><a href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda7b37877e0b9b0df28c9c2b669a633265">Eigen::StrictlyUpper</a></div><div class="ttdeci">@ StrictlyUpper</div><div class="ttdef"><b>Definition:</b> Constants.h:218</div></div>
<div class="ttc" id="agroup__enums_html_gga39e3366ff5554d731e7dc8bb642f83cda8f40b928c10a71ba03e5f75ad2a72fda"><div class="ttname"><a href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cda8f40b928c10a71ba03e5f75ad2a72fda">Eigen::UnitLower</a></div><div class="ttdeci">@ UnitLower</div><div class="ttdef"><b>Definition:</b> Constants.h:212</div></div>
<div class="ttc" id="agroup__enums_html_gga39e3366ff5554d731e7dc8bb642f83cdadd28224d7ea92689930be73c1b50b0ad"><div class="ttname"><a href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdadd28224d7ea92689930be73c1b50b0ad">Eigen::UnitUpper</a></div><div class="ttdeci">@ UnitUpper</div><div class="ttdef"><b>Definition:</b> Constants.h:214</div></div>
</div><!-- fragment -->  </td></tr>
</table>
<dl class="section see"><dt>See also</dt><dd>class <a class="el" href="classEigen_1_1TriangularView.html" title="Expression of a triangular part in a matrix.">TriangularView</a>, class <a class="el" href="classEigen_1_1SelfAdjointView.html" title="Expression of a selfadjoint matrix from a triangular part of a dense matrix.">SelfAdjointView</a></dd></dl>
<h1><a class="anchor" id="TriangularSolveInPlace"></a>
Triangular in-place solving</h1>
<table class="manual">
<tr>
<th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2</th><th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3 </th></tr>
<tr>
<td><div class="fragment"><div class="line">A.triangularSolveInPlace&lt;XxxTriangular&gt;(Y);</div>
</div><!-- fragment --></td><td><div class="fragment"><div class="line">A.triangularView&lt;Xxx&gt;().solveInPlace(Y);</div>
</div><!-- fragment --> </td></tr>
</table>
<h1><a class="anchor" id="Decompositions"></a>
Matrix decompositions</h1>
<p>Some of <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2's matrix decompositions have been renamed in <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3, while some others have been removed and are replaced by other decompositions in <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3.</p>
<table class="manual">
<tr>
<th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2 </th><th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3 </th><th>Notes  </th></tr>
<tr>
<td>LU </td><td><a class="el" href="classEigen_1_1FullPivLU.html" title="LU decomposition of a matrix with complete pivoting, and related features.">FullPivLU</a> </td><td class="alt">See also the new <a class="el" href="classEigen_1_1PartialPivLU.html" title="LU decomposition of a matrix with partial pivoting, and related features.">PartialPivLU</a>, it's much faster  </td></tr>
<tr>
<td>QR </td><td><a class="el" href="classEigen_1_1HouseholderQR.html" title="Householder QR decomposition of a matrix.">HouseholderQR</a> </td><td class="alt">See also the new <a class="el" href="classEigen_1_1ColPivHouseholderQR.html" title="Householder rank-revealing QR decomposition of a matrix with column-pivoting.">ColPivHouseholderQR</a>, it's more reliable  </td></tr>
<tr>
<td>SVD </td><td><a class="el" href="classEigen_1_1JacobiSVD.html" title="Two-sided Jacobi SVD decomposition of a rectangular matrix.">JacobiSVD</a> </td><td class="alt">We currently don't have a bidiagonalizing SVD; of course this is planned.  </td></tr>
<tr>
<td><a class="el" href="classEigen_1_1EigenSolver.html" title="Computes eigenvalues and eigenvectors of general matrices.">EigenSolver</a> and friends </td><td><div class="fragment"><div class="line"><span class="preprocessor">#include&lt;Eigen/Eigenvalues&gt;</span> </div>
</div><!-- fragment -->  </td><td class="alt">Moved to separate module  </td></tr>
</table>
<h1><a class="anchor" id="LinearSolvers"></a>
Linear solvers</h1>
<table class="manual">
<tr>
<th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2</th><th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3</th><th>Notes </th></tr>
<tr>
<td><div class="fragment"><div class="line">A.lu();</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">A.fullPivLu();</div>
</div><!-- fragment --> </td><td class="alt">Now A.lu() returns a <a class="el" href="classEigen_1_1PartialPivLU.html" title="LU decomposition of a matrix with partial pivoting, and related features.">PartialPivLU</a> </td></tr>
<tr>
<td><div class="fragment"><div class="line">A.lu().solve(B,&amp;X);</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">X = A.lu().solve(B);</div>
<div class="line">X = A.fullPivLu().solve(B);</div>
</div><!-- fragment --> </td><td class="alt">The returned by value is fully optimized </td></tr>
<tr>
<td><div class="fragment"><div class="line">A.llt().solve(B,&amp;X);</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">X = A.llt().solve(B);</div>
<div class="line">X = A.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Lower</a>&gt;.llt().solve(B);</div>
<div class="line">X = A.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Upper</a>&gt;.llt().solve(B);</div>
</div><!-- fragment --> </td><td class="alt">The returned by value is fully optimized and <br  />
the selfadjointView API allows you to select the <br  />
triangular part to work on (default is lower part) </td></tr>
<tr>
<td><div class="fragment"><div class="line">A.llt().solveInPlace(B);</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">B = A.llt().solve(B);</div>
<div class="line">B = A.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Lower</a>&gt;.llt().solve(B);</div>
<div class="line">B = A.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Upper</a>&gt;.llt().solve(B);</div>
</div><!-- fragment --> </td><td class="alt">In place solving </td></tr>
<tr>
<td><div class="fragment"><div class="line">A.ldlt().solve(B,&amp;X);</div>
</div><!-- fragment --> </td><td><div class="fragment"><div class="line">X = A.ldlt().solve(B);</div>
<div class="line">X = A.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdaf581029282d421eee5aae14238c6f749">Lower</a>&gt;.ldlt().solve(B);</div>
<div class="line">X = A.selfadjointView&lt;<a class="code" href="group__enums.html#gga39e3366ff5554d731e7dc8bb642f83cdafca2ccebb604f171656deb53e8c083c1">Upper</a>&gt;.ldlt().solve(B);</div>
</div><!-- fragment --> </td><td class="alt">The returned by value is fully optimized and <br  />
the selfadjointView API allows you to select the <br  />
triangular part to work on </td></tr>
</table>
<h1><a class="anchor" id="GeometryModule"></a>
Changes in the Geometry module</h1>
<p>The Geometry module is the one that changed the most. If you rely heavily on it, it's probably a good idea to use the <a href="http://eigen.tuxfamily.org/dox-3.2/Eigen2SupportModes.html">"Eigen 2 support modes"</a> to perform your migration.</p>
<h1><a class="anchor" id="Transform"></a>
The Transform class</h1>
<p>In <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2, the <a class="el" href="classEigen_1_1Transform.html" title="Represents an homogeneous transformation in a N dimensional space.">Transform</a> class didn't really know whether it was a projective or affine transformation. In <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3, it takes a new <em>Mode</em> template parameter, which indicates whether it's <em>Projective</em> or <em>Affine</em> transform. There is no default value.</p>
<p>The Transform3f (etc) typedefs are no more. In <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3, the <a class="el" href="classEigen_1_1Transform.html" title="Represents an homogeneous transformation in a N dimensional space.">Transform</a> typedefs explicitly refer to the <em>Projective</em> and <em>Affine</em> modes:</p>
<table class="manual">
<tr>
<th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2</th><th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3</th><th>Notes </th></tr>
<tr>
<td>Transform3f  </td><td>Affine3f or Projective3f  </td><td>Of course 3f is just an example here   </td></tr>
</table>
<h1><a class="anchor" id="LazyVsNoalias"></a>
Lazy evaluation and noalias</h1>
<p>In <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> all operations are performed in a lazy fashion except the matrix products which are always evaluated into a temporary by default. In Eigen2, lazy evaluation could be enforced by tagging a product using the .lazy() function. However, in complex expressions it was not easy to determine where to put the lazy() function. In Eigen3, the lazy() feature has been superseded by the <a class="el" href="classEigen_1_1MatrixBase.html#a2c1085de7645f23f240876388457da0b">MatrixBase::noalias()</a> function which can be used on the left hand side of an assignment when no aliasing can occur. Here is an example: </p><div class="fragment"><div class="line">MatrixXf a, b, c;</div>
<div class="line">...</div>
<div class="line">c.noalias() += 2 * a.transpose() * b;</div>
</div><!-- fragment --><p> However, the noalias mechanism does not cover all the features of the old .lazy(). Indeed, in some extremely rare cases, it might be useful to explicit request for a lay product, i.e., for a product which will be evaluated one coefficient at once, on request, just like any other expressions. To this end you can use the <a class="el" href="classEigen_1_1MatrixBase.html#ae0c280b1066c14ed577021f38876527f">MatrixBase::lazyProduct()</a> function, however we strongly discourage you to use it unless you are sure of what you are doing, i.e., you have rigourosly measured a speed improvement.</p>
<h1><a class="anchor" id="AlignMacros"></a>
Alignment-related macros</h1>
<p>The EIGEN_ALIGN_128 macro has been renamed to EIGEN_ALIGN16. Don't be surprised, it's just that we switched to counting in bytes ;-)</p>
<p>The <a class="el" href="TopicPreprocessorDirectives.html#TopicPreprocessorDirectivesPerformance">EIGEN_DONT_ALIGN </a> option still exists in <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3, but it has a new cousin: <a class="el" href="TopicPreprocessorDirectives.html#TopicPreprocessorDirectivesPerformance">EIGEN_DONT_ALIGN_STATICALLY.</a> It allows to get rid of all static alignment issues while keeping alignment of dynamic-size heap-allocated arrays. Vectorization of statically allocated arrays is still preserved (unless you define <a class="el" href="TopicPreprocessorDirectives.html#TopicPreprocessorDirectivesPerformance">EIGEN_UNALIGNED_VECTORIZE </a> =0), at the cost of unaligned memory stores.</p>
<h1><a class="anchor" id="AlignedMap"></a>
Aligned Map objects</h1>
<p>A common issue with <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2 was that when mapping an array with <a class="el" href="classEigen_1_1Map.html" title="A matrix or vector expression mapping an existing array of data.">Map</a>, there was no way to tell <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> that your array was aligned. There was a ForceAligned option but it didn't mean that; it was just confusing and has been removed.</p>
<p>New in Eigen3 is the <a class="el" href="group__enums.html#gga45fe06e29902b7a2773de05ba27b47a1ae12d0f8f869c40c76128260af2242bc8">Aligned</a> option. See the documentation of class <a class="el" href="classEigen_1_1Map.html" title="A matrix or vector expression mapping an existing array of data.">Map</a>. Use it like this: </p><div class="fragment"><div class="line">Map&lt;Vector4f, Aligned&gt; myMappedVector(some_aligned_array);</div>
</div><!-- fragment --><p> There also are related convenience static methods, which actually are the preferred way as they take care of such things as constness: </p><div class="fragment"><div class="line">result = <a class="code" href="classEigen_1_1PlainObjectBase.html#ae618ce2543ce8deef2a838864de2b610">Vector4f::MapAligned</a>(some_aligned_array);</div>
<div class="ttc" id="aclassEigen_1_1PlainObjectBase_html_ae618ce2543ce8deef2a838864de2b610"><div class="ttname"><a href="classEigen_1_1PlainObjectBase.html#ae618ce2543ce8deef2a838864de2b610">Eigen::PlainObjectBase&lt; Matrix&lt; _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols &gt; &gt;::MapAligned</a></div><div class="ttdeci">static ConstAlignedMapType MapAligned(const Scalar *data)</div><div class="ttdef"><b>Definition:</b> PlainObjectBase.h:600</div></div>
</div><!-- fragment --><h1><a class="anchor" id="StdContainers"></a>
STL Containers</h1>
<p>In Eigen2, <code>#include&lt;Eigen/StdVector&gt;</code> tweaked std::vector to automatically align elements. The problem was that that was quite invasive. In Eigen3, we only override standard behavior if you use Eigen::aligned_allocator&lt;T&gt; as your allocator type. So for example, if you use std::vector&lt;Matrix4f&gt;, you need to do the following change (note that <a class="el" href="classEigen_1_1aligned__allocator.html" title="STL compatible allocator to use with types requiring a non standrad alignment.">aligned_allocator</a> is under namespace <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a>):</p>
<table class="manual">
<tr>
<th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 2</th><th><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> 3 </th></tr>
<tr>
<td><div class="fragment"><div class="line">std::vector&lt;Matrix4f&gt; </div>
</div><!-- fragment -->  </td><td><div class="fragment"><div class="line">std::vector&lt;Matrix4f, aligned_allocator&lt;Matrix4f&gt; &gt; </div>
</div><!-- fragment -->   </td></tr>
</table>
<h1><a class="anchor" id="eiPrefix"></a>
Internal ei_ prefix</h1>
<p>In Eigen2, global internal functions and structures were prefixed by <code>ei_</code>. In Eigen3, they all have been moved into the more explicit <code>internal</code> namespace. So, e.g., <code>ei_sqrt(x)</code> now becomes <code>internal::sqrt(x)</code>. Of course it is not recommended to rely on <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a>'s internal features. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Wed Aug 18 2021 14:16:25 for Eigen by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
